SHAPE_FILE_LAMB93=data/raw_data/geography/shapeFile/CantonId.shp # Shape file used to plot maps

mkdir -p exhibits/figures
mkdir -p exhibits/figures_inputs
mkdir -p exhibits/tables_inputs

### Figure 2
cp results/EDA/summaryTimeLags/timeLag_consumer1stTransaction_Histogram.pdf exhibits/figures/fig2a.pdf
cp results/EDA/summaryTimeLags/timeLag_providerAccountCreation1stTransaction_Histogram.pdf exhibits/figures/fig2b.pdf

### Figure 3
cp results/EDA/fig3a.pdf exhibits/figures/fig3a.pdf
cp results/EDA/fig3b.pdf exhibits/figures/fig3b.pdf

### Figure 4: make adoption maps from csv files
CUTOFF_JSON_FILE=results/EDA/adoptionMaps/map_color_cutoffs.json
MYLEGEND_PDF=results/EDA/adoptionMaps/legend.pdf

# Make cutoff file
echo '{"CumulativeConsumersPer100000People": [1.0, 3.0, 6.0, 12.0, 18.0, 24.0, 36.0, 50.0], "CumulativeProvidersPer100000People": [1.0, 3.0, 6.0, 12.0, 18.0, 24.0, 36.0, 50.0]}' >$CUTOFF_JSON_FILE

# Make maps
for MYDATE in '2013-01-01' '2013-09-01' '2014-04-01'; do
    for MYSIDE in consumer provider; do
        INPUT_CSV=results/EDA/adoptionMaps/InstalledBasePerCapita_${MYSIDE}_${MYDATE}.csv
        OUTPUT_MAP_SVG=results/EDA/adoptionMaps/InstalledBasePerCapita_${MYSIDE}_${MYDATE}.svg
        OUTPUT_MAP_PDF=results/EDA/adoptionMaps/InstalledBasePerCapita_${MYSIDE}_${MYDATE}.pdf
        python3 drawSVGmap.py $OUTPUT_MAP_SVG $SHAPE_FILE_LAMB93 '' $INPUT_CSV 'Cumulative adoptions per capita' $CUTOFF_JSON_FILE
        convert -density 500 $OUTPUT_MAP_SVG $OUTPUT_MAP_PDF                # uses ImageMagick to convert from svg to pdf format (500 dpi resolution)
        if  [[ "$MYDATE" -eq '2013-01-01' && "$MYSIDE" -eq 'consumer' ]]; then
            pdfcrop --margins '-5 -275 -430 -2' $OUTPUT_MAP_PDF $MYLEGEND_PDF # crops pdf (pdfcrop command line tool installed as part of Texlive)
        fi;
        pdfcrop --margins '-120 -55 -28 -5' $OUTPUT_MAP_PDF $OUTPUT_MAP_PDF # crops pdf (pdfcrop is a command line tool installed as part of Texlive)
        rm $OUTPUT_MAP_SVG
     done
done

# Copy maps into exhibits
cp results/EDA/adoptionMaps/InstalledBasePerCapita_consumer_2013-01-01.pdf exhibits/figures_inputs/fig4a1.pdf
cp results/EDA/adoptionMaps/InstalledBasePerCapita_provider_2013-01-01.pdf exhibits/figures_inputs/fig4a2.pdf
cp results/EDA/adoptionMaps/InstalledBasePerCapita_consumer_2013-09-01.pdf exhibits/figures_inputs/fig4b1.pdf
cp results/EDA/adoptionMaps/InstalledBasePerCapita_provider_2013-09-01.pdf exhibits/figures_inputs/fig4b2.pdf
cp results/EDA/adoptionMaps/InstalledBasePerCapita_consumer_2014-04-01.pdf exhibits/figures_inputs/fig4c1.pdf
cp results/EDA/adoptionMaps/InstalledBasePerCapita_provider_2014-04-01.pdf exhibits/figures_inputs/fig4c2.pdf
cp results/EDA/adoptionMaps/legend.pdf exhibits/figures_inputs/fig4_legend.pdf

### Figure 5
cp results/continuous_time/jointProcess/run_201/transacDistances_Histogram.pdf exhibits/figures/fig5.pdf

### Figure 7: Make map from csv file
FIG7_FOLDER=results/continuous_time/consumerAdoptions/run_201/simulation_oneExtraProvider/summing_origins
MY_SVG_CUTOFF_JSON=$FIG7_FOLDER/map_color_cutoffs.json
INPUT_CSV=$FIG7_FOLDER/avgTtlEffect.csv
OUTPUT_MAP_SVG=$FIG7_FOLDER/avgTtlEffect.svg
OUTPUT_MAP_PDF=$FIG7_FOLDER/avgTtlEffect.pdf
MYLEGEND_PDF=$FIG7_FOLDER/map_legend.pdf

echo '{"avgTtlEffect": [1, 1.5, 2, 2.5, 3.5, 5, 7.5, 10]}' >$MY_SVG_CUTOFF_JSON
python3 drawSVGmap.py $OUTPUT_MAP_SVG $SHAPE_FILE_LAMB93 '' $INPUT_CSV '' $MY_SVG_CUTOFF_JSON
convert -density 500 $OUTPUT_MAP_SVG $OUTPUT_MAP_PDF
pdfcrop --margins '-5 -275 -430 -2' $OUTPUT_MAP_PDF $MYLEGEND_PDF
pdfcrop --margins '-120 -55 -28 -5' $OUTPUT_MAP_PDF $OUTPUT_MAP_PDF
rm $OUTPUT_MAP_SVG

cp results/continuous_time/consumerAdoptions/run_201/simulation_oneExtraProvider/summing_origins/avgTtlEffect.pdf exhibits/figures_inputs/fig7.pdf
cp results/continuous_time/consumerAdoptions/run_201/simulation_oneExtraProvider/summing_origins/map_legend.pdf exhibits/figures_inputs/fig7_legend.pdf


### Figure 8: Make map from csv file
FIG8_FOLDER=results/continuous_time/consumerAdoptions/run_201/simulation_oneExtraProvider/fixing_destinations
MY_SVG_CUTOFF_JSON=$FIG8_FOLDER/map_color_cutoffs.json
echo '{"pctEffect": [0.01, 0.02, 0.05, 0.10, 0.20, 0.50, 1.0, 2.0]}' >$MY_SVG_CUTOFF_JSON
MYLEGEND_PDF=$FIG8_FOLDER/map_legend.pdf

for MYCANTON_NAME in Canton2B01 Paris; do
    INPUT_CSV=$FIG8_FOLDER/${MYCANTON_NAME}.csv
    OUTPUT_MAP_SVG=$FIG8_FOLDER/${MYCANTON_NAME}.svg
    OUTPUT_MAP_PDF=$FIG8_FOLDER/${MYCANTON_NAME}.pdf

    python3 drawSVGmap.py $OUTPUT_MAP_SVG $SHAPE_FILE_LAMB93 '' $INPUT_CSV '' $MY_SVG_CUTOFF_JSON 2
    convert -density 500 $OUTPUT_MAP_SVG $OUTPUT_MAP_PDF
    pdfcrop --margins '-5 -275 -430 -2' $OUTPUT_MAP_PDF $MYLEGEND_PDF
    pdfcrop --margins '-120 -55 -28 -5' $OUTPUT_MAP_PDF $OUTPUT_MAP_PDF
done

cp $FIG8_FOLDER/Canton2B01.pdf exhibits/figures_inputs/fig8a.pdf
cp $FIG8_FOLDER/Paris.pdf exhibits/figures_inputs/fig8b.pdf
cp $FIG8_FOLDER/map_legend.pdf exhibits/figures_inputs/fig8_legend.pdf

### Figure 9
cp results/continuous_time/jointProcess/run_201/cnfacts/plots/seeding_by_type/timeseries_laggedConsumers.pdf exhibits/figures/fig9a.pdf
cp results/continuous_time/jointProcess/run_201/cnfacts/plots/seeding_by_type/timeseries_laggedProviders.pdf exhibits/figures/fig9b.pdf

### Figure 10
cp results/continuous_time/jointProcess/run_201/cnfacts/plots/seeding_providers_by_location/timeseries_laggedConsumers.pdf exhibits/figures/fig10a.pdf
cp results/continuous_time/jointProcess/run_201/cnfacts/plots/seeding_providers_by_location/timeseries_laggedProviders.pdf exhibits/figures/fig10b.pdf

### Figure W2
cp results/EDA/figW2a.pdf exhibits/figures/figW2a.pdf
cp results/EDA/figW2b.pdf exhibits/figures/figW2b.pdf


### Figure W3
cp results/continuous_time/jointProcess/run_201/dynamicPredictions/timeseries_consumerAdoptions.pdf exhibits/figures/figW3a.pdf
cp results/continuous_time/jointProcess/run_201/dynamicPredictions/timeseries_providerAdoptions.pdf exhibits/figures/figW3b.pdf
cp results/continuous_time/jointProcess/run_201/dynamicPredictions/timeseries_providerExits.pdf exhibits/figures/figW3c.pdf
cp results/continuous_time/jointProcess/run_201/dynamicPredictions/timeseries_laggedConsumers.pdf exhibits/figures/figW3d.pdf
cp results/continuous_time/jointProcess/run_201/dynamicPredictions/timeseries_laggedProviders.pdf exhibits/figures/figW3e.pdf

# Figure 11
cp results/continuous_time/jointProcess/run_201/cnfacts/cnfact6/AdvData.csv exhibits/figures_inputs/fig11_AdvData.csv

###########

### Table 3
cp results/EDA/table3.csv exhibits/tables_inputs/tab3.csv

### Table 4
cp results/continuous_time/jointProcess/run_201/estimates/consumerAdoptions.csv exhibits/tables_inputs/tab4_consumerAdoptions.csv
cp results/continuous_time/jointProcess/run_201/estimates/providerAdoptions.csv exhibits/tables_inputs/tab4_providerAdoptions.csv
cp results/continuous_time/jointProcess/run_201/estimates/providerExits.csv exhibits/tables_inputs/tab4_providerExits.csv
cp results/continuous_time/jointProcess/run_201/estimates/modelFits.csv exhibits/tables_inputs/tab4_modelFits.csv


### Table 5
cp results/continuous_time/consumerAdoptions/run_201/elasticities/elasticitiesStrings.csv exhibits/tables_inputs/tab5_a_consumerAdoptions.csv
cp results/continuous_time/providerAdoptions/run_201/elasticities/elasticitiesStrings.csv exhibits/tables_inputs/tab5_a_providerAdoptions.csv
cp results/continuous_time/providerExits/run_201/elasticities/elasticitiesStrings.csv     exhibits/tables_inputs/tab5_a_providerExits.csv

cp results/continuous_time/consumerAdoptions/run_201/multiplyingFactors/multiplyingFactors2.csv exhibits/tables_inputs/tab5_b_consumerAdoptions.csv
cp results/continuous_time/providerAdoptions/run_201/multiplyingFactors/multiplyingFactors2.csv exhibits/tables_inputs/tab5_b_providerAdoptions.csv
cp results/continuous_time/providerExits/run_201/multiplyingFactors/multiplyingFactors2.csv exhibits/tables_inputs/tab5_b_providerExits.csv


### tables_inputs W2, W3, W4
cp results/continuous_time/jointProcess/run_201/paramRecovery/continuous_time/consumerAdoptions_results.csv exhibits/tables_inputs/tabW2.csv
cp results/continuous_time/jointProcess/run_201/paramRecovery/continuous_time/providerAdoptions_results.csv exhibits/tables_inputs/tabW3.csv
cp results/continuous_time/jointProcess/run_201/paramRecovery/continuous_time/providerExits_results.csv exhibits/tables_inputs/tabW4.csv

### tables_inputs W5, W6, W7
cp results/continuous_time/jointProcess/run_201/paramRecovery/day_level/consumerAdoptions_results.csv exhibits/tables_inputs/tabW5.csv
cp results/continuous_time/jointProcess/run_201/paramRecovery/day_level/providerAdoptions_results.csv exhibits/tables_inputs/tabW6.csv
cp results/continuous_time/jointProcess/run_201/paramRecovery/day_level/providerExits_results.csv exhibits/tables_inputs/tabW7.csv

### Table W8
cp results/continuous_time/jointProcess/run_201/freqTable_daily.csv exhibits/tables_inputs/tabW8.csv

### Table W9
cp results/continuous_time/jointProcess/run_201/freqTable_weekly.csv exhibits/tables_inputs/tabW9.csv

### tables_inputs W10, W11, W12
cp results/continuous_time/jointProcess/run_201/robustCheckDiscrete/consumerAdoptions.csv exhibits/tables_inputs/tabW10.csv
cp results/continuous_time/jointProcess/run_201/robustCheckDiscrete/providerAdoptions.csv exhibits/tables_inputs/tabW11.csv
cp results/continuous_time/jointProcess/run_201/robustCheckDiscrete/providerExits.csv exhibits/tables_inputs/tabW12.csv

### Table W13
cp results/day_level/jointProcess/run_101/estimates/consumerAdoptions.csv exhibits/tables_inputs/tabW13_consumerAdoptions.csv
cp results/day_level/jointProcess/run_101/estimates/providerAdoptions.csv exhibits/tables_inputs/tabW13_providerAdoptions.csv
cp results/day_level/jointProcess/run_101/estimates/providerExits.csv     exhibits/tables_inputs/tabW13_providerExits.csv
cp results/day_level/jointProcess/run_101/estimates/modelFits.csv         exhibits/tables_inputs/tabW13_modelFits.csv

### Table W14
cp results/week_level/jointProcess/run_001/estimates/consumerAdoptions.csv exhibits/tables_inputs/tabW14_consumerAdoptions.csv
cp results/week_level/jointProcess/run_001/estimates/providerAdoptions.csv exhibits/tables_inputs/tabW14_providerAdoptions.csv
cp results/week_level/jointProcess/run_001/estimates/providerExits.csv     exhibits/tables_inputs/tabW14_providerExits.csv
cp results/week_level/jointProcess/run_001/estimates/modelFits.csv         exhibits/tables_inputs/tabW14_modelFits.csv


### Table W15
cp results/continuous_time/jointProcess/run_206/estimates/consumerAdoptions.csv exhibits/tables_inputs/tabW15_consumerAdoptions.csv
cp results/continuous_time/jointProcess/run_206/estimates/providerAdoptions.csv exhibits/tables_inputs/tabW15_providerAdoptions.csv
cp results/continuous_time/jointProcess/run_206/estimates/providerExits.csv exhibits/tables_inputs/tabW15_providerExits.csv
cp results/continuous_time/jointProcess/run_206/estimates/modelFits.csv exhibits/tables_inputs/tabW15_modelFits.csv

### Table W16
cp results/continuous_time/jointProcess/run_205/estimates/consumerAdoptions.csv exhibits/tables_inputs/tabW16_model1_consumerAdoptions.csv
cp results/continuous_time/jointProcess/run_205/estimates/modelFits.csv exhibits/tables_inputs/tabW16_model1_modelFits.csv
cp results/continuous_time/jointProcess/run_204/estimates/consumerAdoptions.csv exhibits/tables_inputs/tabW16_model2_consumerAdoptions.csv
cp results/continuous_time/jointProcess/run_204/estimates/modelFits.csv exhibits/tables_inputs/tabW16_model2_modelFits.csv
cp results/continuous_time/jointProcess/run_203/estimates/consumerAdoptions.csv exhibits/tables_inputs/tabW16_model3_consumerAdoptions.csv
cp results/continuous_time/jointProcess/run_203/estimates/modelFits.csv exhibits/tables_inputs/tabW16_model3_modelFits.csv
cp results/continuous_time/jointProcess/run_202/estimates/consumerAdoptions.csv exhibits/tables_inputs/tabW16_model4_consumerAdoptions.csv
cp results/continuous_time/jointProcess/run_202/estimates/modelFits.csv exhibits/tables_inputs/tabW16_model4_modelFits.csv
cp results/continuous_time/jointProcess/run_201/estimates/consumerAdoptions.csv exhibits/tables_inputs/tabW16_model5_consumerAdoptions.csv
cp results/continuous_time/jointProcess/run_201/estimates/modelFits.csv exhibits/tables_inputs/tabW16_model5_modelFits.csv

### Table W17
cp results/continuous_time/pairAdoptions/run_201/results2.csv exhibits/tables_inputs/tabW17.csv

### Table W18
cp results/continuous_time/acctCreation/run_002/results2.csv exhibits/tables_inputs/tabW18a.csv
cp results/continuous_time/acctCreation/run_001/results2.csv exhibits/tables_inputs/tabW18b.csv
cp results/continuous_time/acctCreation/run_003/results2.csv exhibits/tables_inputs/tabW18c.csv
cp results/continuous_time/acctCreation/modelFits.csv exhibits/tables_inputs/tabW18_modelFits.csv

